<template>



	<el-container>

		<el-header style="text-align: center; font-size: 18px">
			<i class="el-icon-s-check" style="margin-right: 15px"></i>

			<span>患者信息界面</span>
		</el-header>

		<el-main>
			<el-table :data="tableData" style="width: 100%" :default-sort="{prop: 'date', order: 'descending'}">

				<el-table-column prop="date" label="序号" sortable width="180">
				</el-table-column>
				<el-table-column prop="name" label="姓名" width="180">
				</el-table-column>

				<el-table-column prop="age" label="年龄" sortable width="180">
				</el-table-column>

				<el-table-column prop="sex" label="性别" width="180">
				</el-table-column>

				<el-table-column prop="address" label="地址" :formatter="formatter">
				</el-table-column>

				<el-table-column prop="phone" label="手机号" width="180">
				</el-table-column>

				<el-table-column prop="state" label="病情" width="180">
				</el-table-column>

				<el-table-column fixed="right" label="操作" width="120">
					<template slot-scope="scope">
						<el-button type="text" @click="open" size="small">
							查看详情
						</el-button>
					</template>
				</el-table-column>
				<el-table-column fixed="right" label="" width="120">
					<template slot-scope="scope">
						<el-button type="text" @click="open" size="small">

						</el-button>
					</template>
				</el-table-column>
				<el-table-column fixed="right" label="" width="120">
					<template slot-scope="scope">
						<el-button type="text" @click="open" size="small">

						</el-button>
					</template>
				</el-table-column>
				<!-- <el-table-column
				       fixed="right"
				       label="操作"
				       width="120">
				       <template slot-scope="scope">
				         <el-button
				           @click.native.prevent="deleteRow(scope.$index, tableData)"
				           type="text"
				           size="small" >
				           移除
				         </el-button>
				       </template>
				     </el-table-column> -->
			</el-table>
		</el-main>
		<el-pagination style="align-items: center;" background layout="prev, pager, next" :total="20">
		</el-pagination>
		<el-footer>Footer</el-footer>

	</el-container>


</template>

<script>
	import {
		showMsgTitle
	} from '@/utils/api'
	import {
		showMsgConfirm
	} from '@/utils/api'
	import {
		getRequest
	} from '@/utils/api'

	export default {
		data() {
			return {
				tableData: [{}]
				
			}
		},
		mounted: function() {
			let url = "/doctor/patient";
			let _this = this;
			getRequest(url).then(resp => {
				if (resp.status == 200) {
					//alert(resp.data);
					_this.tableData = resp.data;
				} else {
					_this.$message({
						type: 'error',
						message: '数据加载失败!'
					});
				}
			}, resp => {
				_this.loading = false;
				if (resp.response.status == 403) {
					_this.$message({
						type: 'error',
						message: resp.response.data
					});
				} else {
					_this.$message({
						type: 'error',
						message: '数据加载失败!'
					});
				}
			}).catch(resp => {
				//压根没见到服务器
				_this.loading = false;
				_this.$message({
					type: 'error',
					message: '数据加载失败!'
				});
			});
			// this.axios.get('/api/user/allUser')
			// 	.then(res => {
			// 		this.tableData = res.data;
			// 	})
			// 	.catch(function(error) {
			// 		console.log(error);
			// 	});
		},
		methods: {
			formatter(row, column) {
				return row.address;
			},
			deleteRow(index, rows) {
				rows.splice(index, 1);
			},
			open() {
				this.$alert('查看成功', '', {
					confirmButtonText: '确 定',
					callback: action => {
						this.$message({
							type: 'info',
							message: `action: ${ action }`
						});
					}
				});
			}
		}
	}
</script>

<style>
	.el-header {
		background-color: #47cfd1;
		color: #333;
		text-align: center;
		line-height: 60px;
	}

	.el-footer {
		background-color: #47cfd1;
		color: #333;
		text-align: center;
		line-height: 60px;
	}

	.el-aside {
		color: #333;
	}
</style>
